package com.example.myapplication.apter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.myapplication.Config.TokenBean;
import com.example.myapplication.R;
import com.example.myapplication.ShuJu.NewsCarouselmapBean;
import com.example.myapplication.ShuJu.ViewlistBean;

import java.util.Collections;
import java.util.List;

public class ViewlistbeanApter extends  RecyclerView.Adapter<ViewlistbeanApter.Myhot>{
    private Context context;
    private List<ViewlistBean.RowsBean> list;

    public ViewlistbeanApter(Context context, List<ViewlistBean.RowsBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public ViewlistbeanApter.Myhot onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_viewlistbean,null);
        return new ViewlistbeanApter.Myhot(view) ;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewlistbeanApter.Myhot holder, int position) {
        /*Glide.with(context).load(TokenBean.IP+list.get(position).getc);*/
        holder.viewlist_name.setText(list.get(position).getUserName());
        holder.viewlist_content.setText(list.get(position).getContent());
        holder.viewlist_time.setText(list.get(position).getCommentDate());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class Myhot extends RecyclerView.ViewHolder{

        private final TextView viewlist_name;
        private final TextView viewlist_content;
        private final TextView viewlist_time;
        private final ImageView viewlist_img;

        public Myhot(@NonNull View itemView) {
            super(itemView);
            viewlist_img = itemView.findViewById(R.id.viewlist_img);
            viewlist_name = itemView.findViewById(R.id.viewlist_name);
            viewlist_content = itemView.findViewById(R.id.viewlist_content);
            viewlist_time = itemView.findViewById(R.id.viewlist_time);
        }
    }
}

